home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
PeerAware 1.03
/
PeerAware-Setup.exe
/
Html
/
scripts
/
toolbar.js
< prev
next >
Wrap
Text File
|
2008-09-07
|
26KB
|
829 lines
/* ***** BEGIN LICENSE BLOCK *****
This code has been relicensed under LGPL as permitted by original license.
Copyright Cumulate Draw Editor
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ***** END LICENSE BLOCK ***** */
function setPageSize2()
{
if (document.documentElement.clientWidth-320>0)
$("_surround").style.width=document.documentElement.clientWidth-320;
refreshColorIndicators();
var t=0;
if (document.documentElement.clientHeight-238-$('_toolbar').clientHeight>0)
{
var t=document.documentElement.clientHeight-238 - $('Selectpalette').clientHeight - $('_toolbar').clientHeight;
if (t<0)
t=100;
$("palette").style.height=t;
}
try
{
if (document.documentElement.clientHeight-281-$('_toolbar').clientHeight>0)
$("_surround").style.height=document.documentElement.clientHeight-281-$('_toolbar').clientHeight;
}
catch (E)
{
}
}
/***operations related to toolbar and shape palette**/
var c;
var currentColorMode="__textColor";
var saveBox;
var uploadBox;
var previousPaletteID="basic"
/**
* new:reset the current canvas
**/
function createNew(){
//var input_box=confirm("Would you like to save your current work before starting a new drawing?\nClick Cancel to procced without saving");
//if(input_box==false){
c.reset();
//}
}
/**
*begin upload (open) by displaying the upload (open) box
*/
function upload(){
if (typeof(window.external)!="undefined" && typeof(window.external.saveFile)!="undefined")
{
loadData(window.external.loadFile());
}
}
/**
*display the 'save as' dialog box
**/
function startSave(){
/* Try.these(c.renderer.savePolyLinePaths());
dummy=c.getRealData();
transmit(aName, 'w', "loa " + dummy);*/
var format=c.renderer.EXTENSION;
var dummy=getAllData(format);
if (typeof(window.external)!="undefined" && typeof(window.external.saveFile)!="undefined")
window.external.saveFile(dummy.innerHTML);
}
/**
*remove the selection box, connection trackers,
* set zoom back to 1.0,getPageSize, fix polyline paths (for IE), and remove text area,
* remove Page, set the zoom factor and size in the data
**/
function getAllData(format){
//now unselect so that the tracker does not travel along!
c.unselect();
var activeLineTracker=$('richdraw').ownerDocument.getElementById("active-shape-tracker");
if(activeLineTracker){
c.renderer.remove(activeLineTracker);
}
//get the zoom
var zoom=c.getZoom();
//add the zoom factor
var dummy=null;
//TODO this needs to be refactored!!! move down to editor
//lets reset the zoom real quick to get the 1.0 zoom level for save
if(c.renderer.TYPE!="SVG"){
c.setZoom((1.0/zoom));
//save the polyline paths
Try.these(c.renderer.savePolyLinePaths());
dummy=c.getRealData();
}
else{
dummy=c.getRealData();
var value=(zoom*(1.0/zoom)).toFixed(2);
c.setShapeZoom(dummy,1.0,zoom);
}
if(c.renderer.TYPE!="SVG"){
c.setZoom(zoom);
}
//End this needs to be refactored
//remove text area
var text=dummy.getElementsByTagName("TEXTAREA")[0];
c.renderer.remove(text);
//remove page
var page=dummy.getElementsByTagName("div")[0];
c.renderer.remove(page);
//add the zoom factor
var zoomElement=c.renderer.createElement("zoom-factor");
zoomElement.setAttribute("factor",zoom);
c.appendPageAttribute(dummy,zoomElement);;
// add size
var size=c.getPageSize();
var pageSize=c.renderer.createElement("page-size");
pageSize.setAttribute("width",size.width);
pageSize.setAttribute("height",size.height);
c.appendPageAttribute(dummy,pageSize);
return dummy;
}
/**
*build the color picker,
*called only once from onload and then cached.
*Notice the select colour method assigned as listener for this color palette
**/
function buildPicker()
{
var Colours = Array('#FFFFFF', '#EDEDED', '#E4E4E4', '#DADADA', '#D1D1D1', '#C7C7C7', '#BDBDBD', '#B3B3B3', '#A8A8A8', '#9E9E9E', '#FF0010', '#FFFE38', '#76FF36', '#00FFFF', '#002CFD', '#EF00FD', '#FB0034', '#FFF125', '#00AE5F', '#00B8EF', '#00429A', '#F30094', '#939393', '#878787', '#7B7B7B', '#6E6E6E', '#626262', '#535353', '#444444', '#343434', '#202020', '#000000', '#FF9C86', '#FFB18D', '#FFC997', '#FFF7A4', '#D8E2A6', '#B5D8A6', '#91CFA6', '#78D3CD', '#08D6F7', '#63AFDA', '#709DCE', '#7D8CC2', '#9D90C2', '#F8A1C6', '#FE9EA5', '#FF715C', '#FF9363', '#FFB26A', '#FFF478', '#C3D680', '#96C981', '#55BF84', '#00C3BB', '#00C7F3', '#0097CE', '#0080BC', '#416AAD', '#7E6BAF','#A66EAF', '#F475AF', '#FB7388', '#FB0034', '#FF6A35', '#FF9936', '#FFF125', '#ADCB52', '#62BC5B', '#00AE5F', '#00B2A6', '#00B8EF', '#0080C1', '#0063AB', '#00429A', '#593C99', '#923397', '#F30094', '#F90066', '#AD001F', '#B34A20', '#B76B21', '#C4A621', '#748F3B', '#408641', '#007E46', '#008076', '#0083AB', '#005A89', '#00437B', '#00256E', '#421E6C', '#68006B', '#A90068', '#AC0047', '#8A0000', '#8D3A00', '#905400', '#998402', '#58712A', '#2E6B31', '#006535', '#00665E', '#006988', '#00456D','#003162', '#000258', '#2F0056', '#540054', '#870052', '#8A0035', '#D3B7A1', '#A88E80', '#816E64', '#625550', '#463D3B', '#D6A279', '#B8855E', '#9E6D49', '#875735', '#744524');
var Obj = document.getElementById("cpicker");
for (var i = 0; i < Colours.length; i++) {
var dDiv = document.createElement("div");
dDiv.style.background = Colours[i];
dDiv.style.width = "10px";
dDiv.style.height = "10px";
dDiv.onclick = selectColour;
Obj.appendChild(dDiv);
}
}
/**
*this method is called after the user selects a text/fill/line color
**/
function selectColour()
{
$('cpicker').style.visibility='hidden';
if(currentColorMode=="__textColor"){
var Obj = document.getElementById("__textColorIndicator");
Obj.style.background = this.style.backgroundColor;
setFontColor(this.style.backgroundColor);
}
else if(currentColorMode=="__fillColor"){
var Obj = document.getElementById("fillColorIndicator");
Obj.style.background = this.style.backgroundColor;
setFillColor(this.style.backgroundColor);
$('linewidth').style.visibility="visible";
}
else if(currentColorMode=="__lineColor"){
var Obj = document.getElementById("lineColorIndicator");
Obj.style.background = this.style.backgroundColor;
setLineColor(this.style.backgroundColor);
$('opacity').style.visibility="visible";
}
//now call the real function
}
/**
* update the page size based on input from the shape properties box
**/
function updatePageSize(){
var width=$("_pageWidth").value;
var height=$("_pageHeight").value;
c.setPageSize(width,height);
var transmitData = "pgs " + width + " " + height;
gApplication.transmit('w', transmitData);
}
/**
*initializes the editor and renderers
**/
function demo() {
var renderer;
ie = navigator.appVersion.match(/MSIE (\d\.\d)/);
opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
if ((!ie) || (opera)) {
renderer = new SVGRenderer();
}
else {
renderer = new VMLRenderer();
//$('_surround').style.width="100%";
//$('_surround').style.height="95%";
//$('palette').style.width="100%";
//$('palette').style.height="91%";
}
c = new RichDrawEditor(document.getElementById('richdraw'), renderer);
c.onselect = onSelect;
c.onunselect = onUnselect;
c.editCommand('fillcolor', 'white');
c.editCommand('linecolor', 'black');
c.editCommand('linewidth', '1px');
setZoom(0.8);
c.setMode('select');
buildPicker();
refreshColorIndicators();
loadRefreshData();
c.updateShapeInfo();
loadPalette('flow-chart');
loadPalette('network');
loadPalette('macui');
loadPalette('windowsui');
loadPalette('workflow');
loadPalette('basic');
show("startdrawing");
c.initializationDone();
}
function refreshColorIndicators() {
$('fillColorIndicator').style.backgroundColor = 'white';
var imageOffset=Position.cumulativeOffset($('__fillColor'));
$('fillColorIndicator').style.left=imageOffset[0]+25;
$('fillColorIndicator').style.top=imageOffset[1]-5;
$('lineColorIndicator').style.backgroundColor = 'black';
imageOffset=Position.cumulativeOffset($('__lineColor'));
$('lineColorIndicator').style.left=imageOffset[0]+25;
$('lineColorIndicator').style.top=imageOffset[1]-5;
imageOffset=Position.cumulativeOffset($('__textColor'));
$('__textColorIndicator').style.left=imageOffset[0]+25;
$('__textColorIndicator').style.top=imageOffset[1];
$('__textColorIndicator').style.backgroundColor='black';
}
/**
* we save the data on the server in case a user hits refresh or leave the page,
* this data can be restored as long as the server session stays alive (10 minutes). this method
* goes to the server to check for any data stored in the session
**/
function loadRefreshData(){
var url = 'ImageProcessor';
var pars="REQUEST_TYPE=PAGE_LOAD";
var myAjax = new Ajax.Request(
url,
{
method: 'post',
parameters: pars,
onComplete: loadRefreshComplete
});
}
/**
*called after refresh complete to redisplay the data
**/
function loadRefreshComplete(originalRequest){
var responseText=originalRequest.responseText;
if(responseText){
var response=responseText;
var div=c.getValidDocumentFromResponse(response)
c.open(div);
}
}
/**
*store the data in user session if user is leaving the page or hits refresh, this
*way we can redisplay if she comes back or after refresh
**/
function storeData(){
var url = 'ImageProcessor';
var dummy=getAllData(c.renderer.EXTENSION);
var data=(dummy.innerHTML)?dummy.innerHTML:dummy.xml;
var pars = 'DATA='+encodeURIComponent(data)+"&REQUEST_TYPE=PAGE_UNLOAD";
var myAjax = new Ajax.Request(
url,
{
method: 'post',
parameters: pars
});
}
/**
* a wrapper on setMode which will set the help text
**/
function setShapeMode(mode,status){
if(mode=='line'||mode=='ortho-line'||mode=='curve-line'){
setHelp("<font color='red'>Connector Mode:</font>To Draw the connector, move your mouse over to the drawing area, click and drag");
}
else if(mode=='text'){
setHelp("<font color='red'>Text Mode:</font>To Draw the Text shape, move your mouse over to the drawing area, click and drag");
}
else if(mode=='select'){
setHelp("<font color='red'>Select Mode</font>");
}
else{
setHelp("To Draw this shape, move your mouse over to the drawing area, click and drag");
//c.renderer.loadShape(mode,null);
}
setMode(mode,status);
}
/**
* set zoom function
**/
function setZoom(zoomfactor){
c.editCommand('zoom',zoomfactor);
$('_zoomValue').innerHTML=(c.getZoom()*100).toFixed(0)+"%";
}
/**
* essentially calls an edit function on the editor
**/
function setMode(mode, status) {
c.editCommand('mode', mode);
if(mode=='line'){
$(mode).style.backgroundColor = '#f8b75d'
$('ortho-line').style.backgroundColor="#f8f8f8";
$('curve-line').style.backgroundColor="#f8f8f8";
$('text').style.backgroundColor="#f8f8f8";
return;
}
else if(mode=='ortho-line'){
$(mode).style.backgroundColor = '#f8b75d'
$('line').style.backgroundColor="#f8f8f8";
$('curve-line').style.backgroundColor="#f8f8f8";
$('text').style.backgroundColor="#f8f8f8";
return;
}
else if(mode=='text'){
$(mode).style.backgroundColor = '#f8b75d'
$('line').style.backgroundColor="#f8f8f8";
$('ortho-line').style.backgroundColor="#f8f8f8";
$('curve-line').style.backgroundColor="#f8f8f8";
return;
}
else if(mode=='curve-line'){
$(mode).style.backgroundColor = '#f8b75d'
$('line').style.backgroundColor="#f8f8f8";
$('ortho-line').style.backgroundColor="#f8f8f8";
$('text').style.backgroundColor="#f8f8f8";
return;
}
else if(mode=='select'){
$('line').style.backgroundColor="#f8f8f8";
$('ortho-line').style.backgroundColor="#f8f8f8";
$('text').style.backgroundColor="#f8f8f8";
$('curve-line').style.backgroundColor="#f8f8f8";
return;
}
else {
$('line').style.backgroundColor="#f8f8f8";
$('ortho-line').style.backgroundColor="#f8f8f8";
$('text').style.backgroundColor="#f8f8f8";
var imgs = $('palette').getElementsByTagName('img');
for (var i=0; i<imgs.length; i++) {
imgs[i].style.backgroundColor = '';
}
$(mode).style.backgroundColor = '#bbbbbb';
}
}
/**
*display or hide the grid background
**/
function setGrid(grid){
var gridValue = grid.options[grid.selectedIndex].value;
var page=$('_page');
if(gridValue=='Grid'){
$('_page').style.backgroundImage="url(images/grid.jpg)";
gApplication.transmit('w', 'cmd grid on');
}
else{
$('_page').style.backgroundImage="";
gApplication.transmit('w', 'cmd grid off');
}
}
/**
* delete the shape
**/
function deleteShape() {
if (c.selected)
gApplication.transmit('w', 'cmd deleteSelection ' + c.selected.id);
setHelp("You can also use the delete key on the keyboard");
c.deleteSelection();
}
/**
* cut, copy, paste operations
**/
function cutShape(){
if (c.selected)
gApplication.transmit('w', 'cmd deleteSelection ' + c.selected.id);
setHelp("To cut, you can also use <b>CTRL+X</b>");
c.cut();
}
function copyShape(){
setHelp("To copy, you can also use <b>CTRL+C</b>");
c.copy();
}
function pasteShape(){
setHelp("To paste, you can also use <b>CTRL+V</b>");
var t=c.paste();
var transmitData = c.renderer.copy(t);
if (transmitData != null)
gApplication.transmit('w', "cpy " + transmitData);
}
/*****************************begin color,fill,gradient,opacity,shadow related operations*************/
function setFillColor(color) {
c.editCommand('fillcolor', color);
}
function setLineColor(color) {
c.editCommand('linecolor', color);
}
function setLineWidth(widths) {
var width = widths.options[widths.selectedIndex].value;
c.editCommand('linewidth', width);
}
/**
* please note this is different than setLineStyle methods which will set the arrow types
*/
function setLineDashStyle(style) {
var style = style.options[style.selectedIndex].value;
c.editCommand('linedashstyle', style);
}
function setOpacity(opacity) {
var opacityValue = opacity.options[opacity.selectedIndex].value;
c.editCommand('opacity',opacityValue);
}
function setShadow(shadow) {
var shadowValue = shadow.options[shadow.selectedIndex].value;
c.editCommand('shadow',shadowValue);
}
function setGradient(gradient) {
var gradientValue= gradient.options[gradient.selectedIndex].value;
c.editCommand('gradient',gradientValue);
}
/*****************************end color,fill,gradient,opacity,shadow related operations***/
/*******************************begin font related functions************************/
function setFontFamily(fontFamily){
var fontFamilyValue=fontFamily.options[fontFamily.selectedIndex].value;
c.editCommand('fontFamily',fontFamilyValue);
}
function setFontSize(fontSize){
var fontSizeValue=fontSize.options[fontSize.selectedIndex].value;
c.editCommand('fontSize',fontSizeValue);
}
function setFontColor(color) {
c.editCommand('fontColor', color);
}
function flipBold(){
c.editCommand('bold',null);
var bold=$('__bold');
if(bold.name=='on'){
bold.name='off';
bold.style.background="#f8f8f8";
}
else{
bold.name='on';
bold.style.background="#f8b75d";
}
}
function flipItalics(){
c.editCommand('italic',null);
var italics=$('__italics');
if(italics.name=='on'){
italics.name='off';
italics.style.background="#f8f8f8";
}
else{
italics.name='on';
italics.style.background="#f8b75d";
}
}
function setAlign(align){
c.editCommand('align',align);
var alignLeft=$('__alignLeft');
if(align=="left"){
alignLeft.style.background="#f8b75d";
}
else{
alignLeft.style.background="#f8f8f8";
}
var alignCenter=$('__alignCenter');
if(align=='center'){
alignCenter.style.background="#f8b75d";
}
else{
alignCenter.style.background="#f8f8f8";
}
var alignRight=$('__alignRight');
if(align=='right'){
alignRight.style.background="#f8b75d";
}
else{
alignRight.style.background="#f8f8f8";
}
}
/***************************end font related functions******************************/
/***************************z-index functions**************************************/
function sendToBack(){
if (c.selected)
gApplication.transmit('w', 'cmd sendtoback ' + c.selected.id);
c.sendToBack();
}
function bringToFront(){
if (c.selected)
gApplication.transmit('w', 'cmd bringtofront ' + c.selected.id);
c.bringToFront();
}
function setUser(aUser){
c.setUser(aUser);
}
function handleRemoteCommand(remoteData){
c.handleRemoteCommand(remoteData);
}
function getOptionByValue(selected, value)
{
if(!selected)return;
for (var i=0; i<selected.length; i++) {
if (selected.options[i].value == value) {
return i;
}
}
return -1;
}
/**
* show the color palette for text/fill/line
**/
function showColorPalette(img){
var cpicker=$('cpicker');
var imageOffset=Position.cumulativeOffset(img);
cpicker.style.visibility="visible";
cpicker.style.position="absolute";
cpicker.style.overflow="visible";
cpicker.style.left=imageOffset[0];
cpicker.style.top=imageOffset[1];
cpicker.style.zIndex=100;
currentColorMode=img.id;
if(img.id=="__fillColor"){
$('linewidth').style.visibility="hidden";
$('fillColorIndicator').style.left=imageOffset[0]+25;
$('fillColorIndicator').style.top=imageOffset[1]-5;
}
else{
$('linewidth').style.visibility="visible";
}
if(img.id=="__lineColor"){
$('opacity').style.visibility="hidden";
$('lineColorIndicator').style.left=imageOffset[0]+25;
$('lineColorIndicator').style.top=imageOffset[1]-5;
}
else{
$('opacity').style.visibility="visible";
}
if(img.id=='__textColor'){
$('__textColorIndicator').style.left=imageOffset[0]+25;
$('__textColorIndicator').style.top=imageOffset[1];
}
}
/**
* called when a shape is selected
* this function can be optimized by setting global vars which refer to these variable
* this way we don't have to do an xml lookup every time!!! In addition it may be good
* idea to return all the attributes in one object rather than return on att at a time
*/
function onSelect() {
$('fillColorIndicator').style.backgroundColor = c.queryCommand('fillcolor');
$('lineColorIndicator').style.backgroundColor = c.queryCommand('linecolor');
$('linewidth').selectedIndex = getOptionByValue($('linewidth'), c.queryCommand('linewidth'));
$('opacity').selectedIndex = getOptionByValue($('opacity'), c.queryCommand('opacity'));
$('gradient').selectedIndex = getOptionByValue($('gradient'), c.queryCommand('gradient'));
$('__shadow').selectedIndex = getOptionByValue($('__shadow'), c.queryCommand('shadow'));
$('__linestyle').selectedIndex = getOptionByValue($('__linestyle'), c.queryCommand('linestyle'));
$('__lineDashStyle').selectedIndex = getOptionByValue($('__lineDashStyle'), c.queryCommand('linedashstyle'));
var font=c.queryCommand('font');
$('__fontfamily').selectedIndex=getOptionByValue($('__fontfamily'), font.family);
$('__fontsize').selectedIndex=getOptionByValue($('__fontsize'), font.size);
$('__textColorIndicator').style.background=font.color;
var bold=$('__bold');
var italic=$('__italics');
if(font.bold=='bold'){
bold.style.background="#f8b75d";
//bold.style.borderColor="#f8f8f8";
bold.name='on';
}
else{
bold.style.background="#f8f8f8";
bold.name='off';
}
if(font.italics=='italic'){
italic.style.background="#f8b75d";
//italic.style.borderColor="#f8f8f8";
italic.name='on';
}
else{
italic.style.background="#f8f8f8";
italic.name='off';
}
//debugger;
var alignLeft=$('__alignLeft');
if(font.align=="left"){
alignLeft.style.background="#f8b75d";
//alignLeft.style.borderColor="#f8f8f8";
}
else{
alignLeft.style.background="#f8f8f8";
//alignLeft.style.borderColor="#f8f8f8";
}
var alignCenter=$('__alignCenter');
if(font.align=='center'){
alignCenter.style.background="#f8b75d";
//alignLeft.style.borderColor="#f8f8f8";
}
else{
alignCenter.style.background="#f8f8f8";
//alignLeft.style.borderColor="#f8f8f8";
}
var alignRight=$('__alignRight');
if(font.align=='right'){
alignRight.style.background="#f8b75d";
//alignLeft.style.borderColor="#f8f8f8";
}
else{
alignRight.style.background="#f8f8f8";
//alignLeft.style.borderColor="#f8f8f8";
}
}
/**
* called when a shape is unselected
* this function can be optimized by setting global vars which refer to these variable
* this way we don't have to do an xml lookup every time!!! In addition it may be good
* idea to return all the attributes in one object rather than return on att at a time
*/
function onUnselect() {
$('fillColorIndicator').style.backgroundColor = c.queryCommand('fillcolor');
$('lineColorIndicator').style.backgroundColor = c.queryCommand('linecolor');
$('linewidth').selectedIndex = getOptionByValue($('linewidth'), c.queryCommand('linewidth'));
$('opacity').selectedIndex = getOptionByValue($('opacity'), c.queryCommand('opacity'));
$('gradient').selectedIndex = getOptionByValue($('gradient'), c.queryCommand('gradient'));
$('__shadow').selectedIndex = getOptionByValue($('__shadow'), c.queryCommand('shadow'));
$('__linestyle').selectedIndex = getOptionByValue($('__linestyle'), c.queryCommand('linestyle'));
var font=c.queryCommand('font');
$('__fontfamily').selectedIndex=getOptionByValue($('__fontfamily'), font.family);
$('__fontsize').selectedIndex=getOptionByValue($('__fontsize'), font.size);
$('__lineDashStyle').selectedIndex = getOptionByValue($('__lineDashStyle'), c.queryCommand('linedashstyle'));
$('__textColorIndicator').style.background=font.color;
var bold=$('__bold');
var italic=$('__italics');
if(font.bold=='bold'){
bold.style.background="#f8b75d";
bold.style.borderColor="#f8f8f8";
bold.name='on';
}
else{
bold.style.background="#f8f8f8";
bold.name='off';
}
if(font.italics=='italic'){
italic.style.background="#f8b75d";
italic.style.borderColor="#f8f8f8";
italic.name='on';
}
else{
italic.style.background="#f8f8f8";
italic.name='off';
}
var alignLeft=$('__alignLeft');
if(font.align=="left"){
alignLeft.style.background="#f8b75d";
//alignLeft.style.borderColor="#f8f8f8";
}
else{
alignLeft.style.background="#f8f8f8";
//alignLeft.style.borderColor="#f8f8f8";
}
var alignCenter=$('__alignCenter');
if(font.align=='center'){
alignCenter.style.background="#f8b75d";
//alignLeft.style.borderColor="#f8f8f8";
}
else{
alignCenter.style.background="#f8f8f8";
//alignLeft.style.borderColor="#f8f8f8";
}
var alignRight=$('__alignRight');
if(font.align=='right'){
alignRight.style.background="#f8b75d";
//alignLeft.style.borderColor="#f8f8f8";
}
else{
alignRight.style.background="#f8f8f8";
//alignLeft.style.borderColor="#f8f8f8";
}
}
/**
*set line style
**/
function setLineStyle(style){
var lineStyle = style.options[style.selectedIndex].value;
c.editCommand('linestyle',lineStyle);
}
/**
* a global function to set help string
* @param {string} help string
**/
function setHelp(helpString){
$('help').innerHTML=helpString;
}
/**
* Load a palette if its not already loaded
* @param {string}id of the containing div
**/
function loadPalette(id){
hide(previousPaletteID);
show(id);
if(!$(id))return;
var div=$(id);
var children=div.getElementsByTagName("div");
if(children.length==0){
var palette=c.loadPalette(id);
div.innerHTML=palette.xml;
previousPaletteID=id;
}
}
function updateShapeProperties() {
var width=$("_width").value;
var height=$("_height").value;
var x=$("_x").value;
var y=$("_y").value;
var rotation=$("_rotation").value;
c.updateShape(width,height,x,y,rotation);
var transmitData = "mvs " + c.selected.id + " " + width + " " + height + " " + x + " " + y + " " + rotation;
gApplication.transmit('w', transmitData);
};
/**
* a utility method to make sure only numbers are entered in the shape properties and page properties
* @credit: Cambia Research:
* @credit:http://www.cambiaresearch.com/cambia3/snippets/javascript/browser/allownumbersonly.aspx
**/
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
/**
* open the quick help window
*/
function openHelpWindow()
{
}